home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc / Developer Documentation / Recipes, Tech Notes & Articles / Tech Notes / Utilities Documentation / PasclStr < prev    next >
Encoding:
Text File  |  1995-11-06  |  3.3 KB  |  63 lines  |  [TEXT/ttxt]

  1. OpenDocâ„¢ Utilities Documentation
  2.  
  3.  
  4. Pascal string routines
  5. 10/31/95
  6.  
  7. © 1993-1995  Apple Computer, Inc. All Rights Reserved.
  8. Apple, the Apple logo, and Macintosh are registered trademarks of Apple Computer, Inc.
  9. Mac and OpenDoc are trademarks of Apple Computer, Inc. 
  10.  
  11.  
  12. Introduction
  13.  
  14. These routines allow manipulation of Pascal strings. These are strings of maximum length 255 characters whose first character is a length byte.
  15.  
  16. Routines
  17.  
  18. StringPtr CToPascalString(char* string);
  19.  
  20. Converts the C string to a Pascal string in place. Returns a pointer to the string passed in.
  21.  
  22. char* PascalToCString(StringPtr string);
  23.  
  24. Converts the Pascal string to a C string in place. Returns a pointer to the string passed in.
  25.  
  26. void ConcatPascalStrings(Str255 destString, ConstStr255Param srcString);
  27.  
  28. Concatenate two Pascal strings together. Error checking is done to ensure that the limit of 255 chars is not exceeded. If it is exceeded, the second string is truncated at a byte boundary that makes sense in the current script.
  29.  
  30. void CopyPascalString(Str255 destString, ConstStr255Param srcString);
  31.  
  32. Copy a Pascal string. The caller must allocate storage (max 256 bytes) for the destination.
  33.  
  34. ODBoolean EqualPascalStrings(ConstStr255Param str1, ConstStr255Param str2);
  35.  
  36. Returns kODTrue if strings are equal, kODFalse otherwise. Does a CASE-INSENSITIVE compare!
  37.  
  38. void CopyISOStr2PStr(Str255 destString, const ODISOStr srcString);
  39.  
  40. Copies an ISO string to a Pascal string. The caller must allocate storage (max 256 bytes) for the destination.
  41.  
  42. StringPtr IntlToPStr(ODIText* intlText, StringPtr pstr);
  43.  
  44. Caller must allocate storage for pstr. No error checking is done for strings longer than 255 chars. Simply grabs the text from the theText field of ODIText. CAUTION: This function is only intended to convert the bytes of the IText to a pascal string. These bytes are not valid without the accompanying script code and language code.
  45.  
  46. ODIText* PStrToIntl(StringPtr pstr, ODIText** intlText);
  47.  
  48. Caller must dispose storage for intlText when done with it. The ODIText is created with theScriptCode = smScriptRoman and theLangCode = langEnglish.  Storage for the ODIText is allocated only if intlText == NULL; otherwise it's assumed that *intlText is a valid ptr to  an ODIText big enough to hold the string. CAUTION: This function is only intended to convert the bytes of the Pascal string to the bytes in an ODIText. These bytes are not valid
  49. without first setting the appropriate accompanying script code and language code in the ODIText as well.
  50.  
  51. ODHandle PStrToText(ConstStr255Param pstr);
  52.  
  53. Allocates an ODHandle and copies the bytes of the Pascal string into it.  Caller must dispose of the returned ODHandle.
  54.  
  55. void TextToPStr(ODHandle textHandle, Str255 destString);
  56.  
  57. Converts the contents of the ODhandle into a Pascal string. The caller must allocate storage for the destination. If the handle is greater than 255 bytes, only the first 255 bytes are copied.
  58.  
  59. ODSShort ClipStringToBytes( Str255 string, ODSShort numBytes,
  60.   ODScriptCode scriptCode );
  61.  
  62. Using the given script code, truncates a pascal string so that it occupies the given number of bytes (plus the length byte) or one less.  The one less case occurs when simple truncation would clip off the second byte of a double-byte character. Returns the number of bytes the truncated string is long, i.e. numBytes or numBytes - 1.
  63.